package eraikikon;

import java.awt.BorderLayout;
import java.sql.SQLException;

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import java.awt.Dimension;
import java.awt.Point;

public class ErabiltzaileakBistaratu extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;
	
	private ResultSetTableModelD tableModel;

	/**
	 * This is the default constructor
	 */
	public ErabiltzaileakBistaratu() {
		super();
		initialize();
		try {
			tableModel=new ResultSetTableModelD("com.mysql.jdbc.Driver","jdbc:mysql://localhost/eraikikon2","ikasle01","ikasle01","SELECT izena, erabiltzaileID, txartelID, guneaID, max(data)as data FROM erabiltzailea NATURAL JOIN sarbideeskaera NATURAL JOIN txartelirakurgailua GROUP BY izena");
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		JTable resultTable= new JTable(tableModel);
		JScrollPane jScrollPane1= new JScrollPane(resultTable,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		jContentPane.add(jScrollPane1, BorderLayout.CENTER);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(531, 135);
		this.setLocation(new Point(400, 200));
		this.setContentPane(getJContentPane());
		this.setTitle("Erabiltzaileen datuak...");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
		}
		return jContentPane;
	}
	public static void main(String [] args){
		ErabiltzaileakBistaratu erabiltzaileakBistaratu=new ErabiltzaileakBistaratu();
		erabiltzaileakBistaratu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		erabiltzaileakBistaratu.setVisible(true);
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
